from my_utils.utils_class.CT import CT
from my_utils.utils_class.CT_button import CTButton
from my_utils.utils_class.FW import FW
from my_utils.utils_class.FW_button import FWButton
from my_utils.utils_funtions.died import on_game_over


def action_game(self):
    self.ui.stackedWidget.setCurrentIndex(1)

    xyf = FW(speed=800)
    xyf.echo_hp()
    xyf.hp_changed.connect(self.ui.progressBar.setValue)
    xyf.hp_changed.emit(100)
    self.xyf_button = FWButton(xyf, self.ui.page_2)
    self.xyf_button.move_randomly()  # 初始坐标
    self.xyf_button.show()

    jbc = CT(speed=1000)
    jbc.echo_action_message()
    jbc.hp_changed.connect(self.ui.CT_progressBar.setValue)
    jbc.hp_changed.emit(100)
    self.jbc_button = CTButton(jbc, self.ui.page_2)
    self.jbc_button.show()
    self.jbc_button.clicked.connect(lambda: self.jbc_button.hit())

    xyf.died.connect(lambda: on_game_over(self, True))
    jbc.died.connect(lambda: on_game_over(self, False))
